package com.ruoyi.feedback.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.feedback.domain.EFeedback;
import com.ruoyi.feedback.service.IEFeedbackService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 反馈信息Controller
 *
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/feedback")
public class EFeedbackController extends BaseController
{
    @Autowired
    private IEFeedbackService eFeedbackService;

    /**
     * 查询反馈信息列表
     */
    @RequiresPermissions("feedback:feedback:list")
    @GetMapping("/list")
    public TableDataInfo list(EFeedback eFeedback)
    {
        startPage();
        List<EFeedback> list = eFeedbackService.selectEFeedbackList(eFeedback);
        return getDataTable(list);
    }

    /**
     * 导出反馈信息列表
     */
    @RequiresPermissions("feedback:feedback:export")
    @Log(title = "反馈信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EFeedback eFeedback)
    {
        List<EFeedback> list = eFeedbackService.selectEFeedbackList(eFeedback);
        ExcelUtil<EFeedback> util = new ExcelUtil<EFeedback>(EFeedback.class);
        util.exportExcel(response, list, "反馈信息数据");
    }

    /**
     * 获取反馈信息详细信息
     */
    @RequiresPermissions("feedback:feedback:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(eFeedbackService.selectEFeedbackById(id));
    }

    /**
     * 新增反馈信息
     */
    @RequiresPermissions("feedback:feedback:add")
    @Log(title = "反馈信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EFeedback eFeedback)
    {
        return toAjax(eFeedbackService.insertEFeedback(eFeedback));
    }

    /**
     * 修改反馈信息
     */
    @RequiresPermissions("feedback:feedback:edit")
    @Log(title = "反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EFeedback eFeedback)
    {
        return toAjax(eFeedbackService.updateEFeedback(eFeedback));
    }

    /**
     * 删除反馈信息
     */
    @RequiresPermissions("feedback:feedback:remove")
    @Log(title = "反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(eFeedbackService.deleteEFeedbackByIds(ids));
    }
    @RequiresPermissions("feedback:feedback:updateFeedback")
    @PutMapping("/updateFeedback")
    public AjaxResult updateFeedback(@RequestBody EFeedback eFeedback)
    {
        return toAjax(eFeedbackService.updateFeedback(eFeedback));
    }

    @RequiresPermissions("feedback:feedback:updateFeedbackText")
    @PutMapping("/updateFeedbackText")
    public AjaxResult updateFeedbackText(@RequestBody EFeedback eFeedback)
    {
        return toAjax(eFeedbackService.updateFeedbackText(eFeedback));
    }
}
